<?php
/**
 * 周舟 hzboye010@163.com
 * addby sublime snippets
 * 论坛帖子 测试类
 */
namespace app\test\controller;

use app\utils\BoyeService;
use app\test\controller\Ava;
class ForumThread extends Ava{

  //置顶
  public function stick(){
		if(IS_AJAX){

		  $data = [
				'tid'          =>I('post.tid',''),
				'uid'          =>I('post.uid',''),
				'stick_value'  =>I('post.stick_value',''),
		    'api_ver'   =>$this->api_ver,
		    'notify_id' =>$this->notify_id,
		    'alg'       =>$this->alg,
		    'type'      =>'BY_ForumThread_stick',
		  ];
		  $service = new BoyeService();
		  $result = $service->callRemote("",$data,true);
		  echo $this->parseResult($result);

		}else{
		  $this->assign('type','BY_ForumThread_stick');
		  $this->assign('field',[
		    ['api_ver',$this->api_ver,LL('need-mark api version')],
		    ['uid',50,LL('need-mark user ID')],
		    ['tid',6083,LL('need-mark thread ID')],
		    ['stick_value',0,LL('need-mark thread-stick')],
		  ]);
		  echo $this->display('ava/test');
		}
  }
  //加精
  public function digest(){
		if(IS_AJAX){

		  $data = [
				'tid'          =>I('post.tid',''),
				'uid'          =>I('post.uid',''),
				'digest_value' =>I('post.digest_value',''),
		    'api_ver'   =>$this->api_ver,
		    'notify_id' =>$this->notify_id,
		    'alg'       =>$this->alg,
		    'type'      =>'BY_ForumThread_digest',
		  ];
		  $service = new BoyeService();
		  $result = $service->callRemote("",$data,true);
		  echo $this->parseResult($result);

		}else{
		  $this->assign('type','BY_ForumThread_digest');
		  $this->assign('field',[
		    ['api_ver',$this->api_ver,LL('need-mark api version')],
		    ['uid',50,LL('need-mark user ID')],
		    ['tid',6083,LL('need-mark thread ID')],
		    ['digest_value',0,LL('need-mark thread-digest')],
		  ]);
		  echo $this->display('ava/test');
		}
  }
  //详情
  public function detail(){
		if(IS_AJAX){
		  $data = [
				'tid'       =>I('post.tid',''),
				'uid'       =>I('post.uid',''),
				'max_reply'   =>I('post.max_reply',''),
				'max_comment' =>I('post.max_comment',''),
				'max_like'    =>I('post.max_like',''),
				'max_img'    =>I('post.max_img',''),
		    'api_ver'   =>$this->api_ver,
		    'notify_id' =>$this->notify_id,
		    'alg'       =>$this->alg,
		    'type'      =>'BY_ForumThread_detail',
		  ];
		  $service = new BoyeService();
		  $result = $service->callRemote("",$data,true);
		  echo $this->parseResult($result);

		}else{
		  $this->assign('type','BY_ForumThread_detail');
		  $this->assign('field',[
		    ['api_ver',$this->api_ver,LL('need-mark api version')],
		    ['tid',6731,LL('need-mark thread ID')],
		    ['uid',50,L('thread-uid')],
				['max_reply',3,LL('max post count')],
		    ['max_comment',2,LL('max comment count')],
		    ['max_like',10,LL('max like count')],
		    ['max_img',3,LL('img-num')],
		  ]);
		  echo $this->display('ava/test');
		}
  }
  //点赞
  public function like(){
		if(IS_AJAX){

		  $data = [
				'tid'       =>I('post.tid',''),
				'pid'       =>I('post.pid',''),
				'uid'       =>I('post.uid',''),
				'like_value'=>I('post.like_value',1),
		    'api_ver'   =>$this->api_ver,
		    'notify_id' =>$this->notify_id,
		    'alg'       =>$this->alg,
		    'type'      =>'BY_ForumThread_like',
		  ];
		  $service = new BoyeService();
		  $result = $service->callRemote("",$data,true);
		  echo $this->parseResult($result);

		}else{
		  $this->assign('type','BY_ForumThread_like');
		  $this->assign('field',[
		    ['api_ver',$this->api_ver,LL('need-mark api version')],
		    ['uid',143,LL('need-mark user ID')],
		    ['tid',383,LL('need-mark thread ID')],
		    ['pid','',LL('post ID')],
		    ['like_value',1,LL('need-mark thread-like')],
		  ]);
		  echo $this->display('ava/test');
		}
  }

  //收藏分页查询
  public function getFavorites(){
		if(IS_AJAX){

		  $data = [
				'uid'       =>I('post.uid',''),
				'fid'       =>I('post.fid',''),
				'page_no'   =>I('post.page_no',''),
				'page_size' =>I('post.page_size',''),
				'img_num'   =>I('post.img_num',''),
				'max_like'   =>I('post.max_like',''),
				'max_reply'  =>I('post.max_reply',''),
				'max_comment'=>I('post.max_comment',''),
		    'api_ver'   =>$this->api_ver,
		    'notify_id' =>$this->notify_id,
		    'alg'       =>$this->alg,
		    'type'      =>'BY_ForumThread_getFavorites',
		  ];
		  $service = new BoyeService();
		  $result = $service->callRemote("",$data,true);
		  echo $this->parseResult($result);

		}else{
		  $this->assign('type','BY_ForumThread_getFavorites');
		  $this->assign('field',[
		    ['api_ver',$this->api_ver,LL('need-mark api version')],
		    ['uid',50,LL('need-mark user ID')],
		    ['fid','',LL('forum ID')],
		    ['page_no',1,L('page')],
		    ['page_size',10,L('page size')],
		    ['img_num',3,L('img-num')],
		    ['max_like',10,L('like-num')],
		    ['max_reply',3,L('reply-num')],
		    ['max_comment',2,L('comment-num')],
		  ]);
		  echo $this->display('ava/test');
		}

  }
  //收藏
  public function favorites(){
		if(IS_AJAX){

		  $data = [
				'tid'            =>I('post.tid',''),
				'uid'            =>I('post.uid',''),
				'favorite_value' =>I('post.favorite_value',''),
		    'api_ver'   =>$this->api_ver,
		    'notify_id' =>$this->notify_id,
		    'alg'       =>$this->alg,
		    'type'      =>'BY_ForumThread_favorites',
		  ];
		  $service = new BoyeService();
		  $result = $service->callRemote("",$data,true);
		  echo $this->parseResult($result);

		}else{
		  $this->assign('type','BY_ForumThread_favorites');
		  $this->assign('field',[
		    ['api_ver',$this->api_ver,LL('need-mark api version')],
		    ['tid',7124,LL('need-mark thread ID')],
		    ['uid',50,LL('need-mark user ID')],
		    ['favorite_value',0,LL('need-mark product-fav-val')],
		  ]);
		  echo $this->display('ava/test');
		}

  }
  //假删除
  public function delete(){
		if(IS_AJAX){

		  $data = [
				'tid'       =>I('post.tid',''),
				'uid'       =>I('post.uid',''),
		    'api_ver'   =>$this->api_ver,
		    'notify_id' =>$this->notify_id,
		    'alg'       =>$this->alg,
		    'type'      =>'BY_ForumThread_delete',
		  ];
		  $service = new BoyeService();
		  $result = $service->callRemote("",$data,true);
		  echo $this->parseResult($result);

		}else{
		  $this->assign('type','BY_ForumThread_delete');
		  $this->assign('field',[
		    ['api_ver',$this->api_ver,LL('need-mark api version')],
		    ['tid',6725,LL('need-mark thread ID')],
		    ['uid',50,LL('need-mark user ID')],
		  ]);
		  echo $this->display('ava/test');
		}

  }
	//发表
	public function add(){
		if(IS_AJAX){

		  $data = [
				'fid'         =>I('post.fid',''),
				'typeid'      =>I('post.typeid',''),
				// 'author'      =>I('post.author',''),
				'author_id'   =>I('post.author_id',''),
				'subject'     =>I('post.subject',''),
				'message'     =>I('post.message',''),
				'attachments' =>I('post.attachments',''),
				'tags' 			  =>I('post.tags',''),
		    'api_ver'   =>$this->api_ver,
		    'notify_id' =>$this->notify_id,
		    'alg'       =>$this->alg,
		    'type'      =>'BY_ForumThread_add',
		  ];
		  $service = new BoyeService();
		  $result = $service->callRemote("",$data,true);
		  echo $this->parseResult($result);

		}else{
		  $this->assign('type','BY_ForumThread_add');
		  $this->assign('field',[
		    ['api_ver',$this->api_ver,LL('need-mark api version')],
		    ['fid',1,LL('need-mark thread-forum ID')],
		    ['typeid','',LL('thread cate ID')],
		    // ['author','初来乍到',LL('need-mark nickname')],
		    ['author_id',50,LL('need-mark user ID')],
		    ['subject','test title',L('title')],
		    ['message','test message',LL('need-mark content')],
		    ['attachments','',L('thread-attach')],
		    ['tags','',L('thread-tag')],
		  ]);
		  echo $this->display('ava/test');
		}
	}
	//帖子修改 - 暂限时光机9
	public function edit(){
		if(IS_AJAX){
		  $data = [
				'tid'       =>I('post.tid',''),
				'uid'       =>I('post.uid',''),
				'subject'     =>I('post.subject',''),
				'message'     =>I('post.message',''),
				'attachments' =>I('post.attachments',''),
				'tags' 			  =>I('post.tags',''),
		    'api_ver'   =>$this->api_ver,
		    'notify_id' =>$this->notify_id,
		    'alg'       =>$this->alg,
		    'type'      =>'BY_ForumThread_edit',
		  ];
		  $service = new BoyeService();
		  $result = $service->callRemote("",$data,true);
		  echo $this->parseResult($result);

		}else{
		  $this->assign('type','BY_ForumThread_edit');
		  $this->assign('field',[
		    ['api_ver',$this->api_ver,LL('need-mark api version')],
		    ['tid',6742,LL('need-mark thread ID')],
		    ['uid',50,LL('user ID')],
		    ['subject','testfid92',L('title')],
		    ['message','test---message',LL('need-mark content')],
		    ['attachments','1,4',L('thread-attach')],
		    ['tags','t1,t4',L('thread-tag')],
		  ]);
		  echo $this->display('ava/test');
		}
	}
  //分页查询
  public function queryBBL(){
		if(IS_AJAX){

		  $data = [
				'uid'       =>I('post.uid',''),
				// 'digest'    =>I('post.digest',''),
				// 'title'     =>I('post.title',''),
				'img_num'   =>I('post.img_num',''),
				'max_reply' =>I('post.max_reply',''),
				// 'max_like'  =>I('post.max_like',''),
				'page_no'   =>I('post.page_no',''),
				'page_size' =>I('post.page_size',''),
				'fresh'     =>I('post.fresh',''),
		    'api_ver'   =>$this->api_ver,
		    'notify_id' =>$this->notify_id,
		    'alg'       =>$this->alg,
		    'type'      =>'BY_ForumThread_queryBBL',
		  ];
		  $service = new BoyeService();
		  $result = $service->callRemote("",$data,true);
		  echo $this->parseResult($result);

		}else{
		  $this->assign('type','BY_ForumThread_queryBBL');
		  $this->assign('field',[
		    ['api_ver',$this->api_ver,LL('need-mark api version')],
		    ['uid','',L('thread-uid')],
		    // ['digest','',L('thread-query-digest')],
		    // ['title','',L('thread-query-title')],
		    ['img_num',3,L('img-num')],
		    ['max_reply',3,LL('max post count')],
		    // ['max_like',10,LL('max like count')],
		    ['page_no',1,L('page')],
		    ['page_size',10,LL('page size')],
		    ['fresh',0,L('if-fresh')],
		  ]);
		  echo $this->display('ava/test');
		}

  }
  //分页查询
  public function query(){
		if(IS_AJAX){

		  $data = [
				'fid'       =>I('post.fid',''),
				'uid'       =>I('post.uid',''),
				'digest'    =>I('post.digest',''),
				'title'     =>I('post.title',''),
				'img_num'   =>I('post.img_num',''),
				'page_no'     =>I('post.page_no',''),
				'max_reply'   =>I('post.max_reply',''),
				'max_comment' =>I('post.max_comment',''),
				'max_like'  =>I('post.max_like',''),
				'page_size' =>I('post.page_size',''),
				'fresh'     =>I('post.fresh',''),
		    'api_ver'   =>$this->api_ver,
		    'notify_id' =>$this->notify_id,
		    'alg'       =>$this->alg,
		    'type'      =>'BY_ForumThread_query',
		  ];
		  $service = new BoyeService();
		  $result = $service->callRemote("",$data,true);
		  echo $this->parseResult($result);

		}else{
		  $this->assign('type','BY_ForumThread_query');
		  $this->assign('field',[
		    ['api_ver',$this->api_ver,LL('need-mark api version')],
		    ['fid','',LL('forum ID')],
		    ['uid','',L('thread-uid')],
		    ['digest','',L('thread-query-digest')],
		    ['title','',L('thread-query-title')],
		    ['img_num',3,L('img-num')],
		    ['max_reply',3,LL('max post count')],
		    ['max_comment',2,LL('max comment count')],
		    ['max_like',10,LL('max like count')],
		    ['page_no',1,L('page')],
		    ['page_size',10,LL('page size')],
		    ['fresh',0,LL('if-fresh')],
		  ]);
		  echo $this->display('ava/test');
		}

  }
  //标签分页查询
  public function tag(){
		if(IS_AJAX){

		  $data = [
				'tag_id'    =>I('post.tag_id',''),
				'fid'       =>I('post.fid',''),
				'uid'       =>I('post.uid',''),
				'max_reply'   =>I('post.max_reply',''),
				'max_comment' =>I('post.max_comment',''),
				'img_num'     =>I('post.img_num',''),
				'page_no'     =>I('post.page_no',''),
				'page_size' =>I('post.page_size',''),
		    'api_ver'   =>$this->api_ver,
		    'notify_id' =>$this->notify_id,
		    'alg'       =>$this->alg,
		    'type'      =>'BY_ForumThread_tag',
		  ];
		  $service = new BoyeService();
		  $result = $service->callRemote("",$data,true);
		  echo $this->parseResult($result);

		}else{
		  $this->assign('type','BY_ForumThread_tag');
		  $this->assign('field',[
		    ['api_ver',$this->api_ver,LL('need-mark api version')],
		    ['tag_id','',LL('need-mark tag ID')],
		    ['fid','',LL('forum ID')],
		    ['uid','',L('thread-uid')],
		    ['img_num',3,L('img-num')],
		    ['max_reply',3,LL('max post count')],
		    ['max_comment',2,LL('max comment count')],
		    ['page_no',1,L('page')],
		    ['page_size',10,LL('page size')],
		  ]);
		  echo $this->display('ava/test');
		}

  }
}